<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\ApiController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class UploadImgController extends ApiController
{
    public function upload(Request $request)
    {
        $file = $request->file('file');
        if ($file && $file->isValid()) {
            $path = $file->store('public/upload');
            return $this->okReturn([
                'path' => Storage::url($path),
            ]);
        } 
        return $this->errorReturn('upload error');
    }
}
